﻿var area;
layui.use(['element', 'jquery', 'form', 'layedit', 'flow'], function () {
    var element = layui.element;
    var form = layui.form;
    var $ = layui.jquery;
    var layedit = layui.layedit;
    var flow = layui.flow;
    //留言的编辑器
    var editIndex = layedit.build('contents', {
        height: 150,
        tool: ['face', '|', 'link'],
    });
    //留言的编辑器的验证
    form.verify({
        content: function (value) {
            value = $.trim(layedit.getContent(editIndex));
            var replyName = localStorage.getItem("admin");
			var img=localStorage.getItem("userAvatar");
			var obj = new Object();
			obj.img = img;
			obj.replyName = replyName;
			obj.content = value
			obj.browse = "谷歌";
			obj.adress = "深圳";
			obj.osname = "win10";
			obj.replyBody = "";
			
			$(".comment-list").addCommentList({ data: [], add: obj });
			console.log(obj)
			$.ajax({
				url: "http://127.0.0.1:8000/answerinsert",
				type: "post",
				dataType: "JSON",
				data: {
					"img": img,
					"replyName": replyName,
					'content': value,
					'browse': "谷歌",//需改静态
					'osname': "win7",//需改静态
					'replyBody': "",
					"address": "深圳",//需改静态
					"time": getNowDateFormat()
				},
				success: function (res) {
					if (res.code > 0) {
						layer.msg(res.msg);
						console.log(res)
					}
					if (res.code == 0) {
						layer.msg(res.msg);
						console.log(res)
					}
					
				}
			})
			window.location.reload()
        }
       
    });
 
});
 
